package ua.kratik.seabattle.game;

/**
 * Represents coordinates of point in battle area
 * @author Andrii_Kratik
 */
public class Coordinates {
	
	private int x;
	private int y;

	/**
	 * Sets both coordinates. Numeration begins from 0.
	 * 
	 * @param x value to set <code>this.x</code>
	 * @param y value to set <code>this.y</code>
	 */
	public Coordinates(int x, int y){
		this.x = x;
		this.y = y;
	}

	/**
	 * @return <code>x</code> coordinate. Numeration begins from 0.
	 */
	public int getX() {
		return x;
	}

	/**
	 * @return <code>y</code> coordinate. Numeration begins from 0.
	 */
	public int getY() {
		return y;
	}

	@Override
	public String toString() {
		return "(x=" + x + ", y=" + y + ")";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Coordinates other = (Coordinates) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		return true;
	}
}
